﻿@using DirectSell.Model.Manager
@model Managers
@{
    ViewBag.Title = "Index";
    Layout = "~/Areas/Manager/Views/Shared/ManagerLayout.cshtml";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form1">
        <div class="row cl" style="display:none">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>Id：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" readonly="readonly" class="input-text" value="@Model.Id" required placeholder="ID" id="Id" name="Id">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ManagerName" required placeholder="管理员姓名" id="ManagerName" name="ManagerName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>账号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ManagerCode" required placeholder="用于登陆" id="ManagerCode" name="ManagerCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ManagerPassWord" required placeholder="密码" id="ManagerPassword" name="ManagerPassword">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
    </form>
</article>
<script>
    $('#form1').on('submit', function(){
        layer.confirm('确定要修改资料？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            formPost();
        }, function () {
            layer.close();
        });
        event.preventDefault() //阻止form表单默认提交
    })
    function formPost() {
        //加载层
        var index = layer.load(1, {
            shade: [0.1, '#fff']
        });
        $.ajax({
            type: "post",
            url: "/Manager/Admin/EditMessage",
            data: $('#form1').serialize(),
        }).success(function (message) {
            if (message != '修改成功') {
                layer.msg(message, { icon: 2 });
            }
            else {
                layer.msg('资料修改成功', { icon: 1 });
            }
        }).fail(function (err) {
            layer.msg('系统错误,请稍后重试', { icon: 2 });
        })
        layer.close(index)//关闭加载层
    }
</script>
